<template>
  <div>
    <!-- 面包屑导航区 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>保险订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图 -->
    <el-card>
      <!-- 用户列表区域 -->
      <el-table :data="OrderData.data" border stripe>
        <el-table-column label="保险名称" prop="name" align="center"></el-table-column>
        <el-table-column label="保险类型" prop="type" align="center"></el-table-column>
        <el-table-column label="生效时间" prop="time" align="center"></el-table-column>
        <el-table-column label="生效状态" prop="status" align="center"></el-table-column>
        <el-table-column label="理赔状态" prop="claim" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button size="mini" @click="$router.push('/Updateorder/'+scope.row._id)">修改</el-button>
            <el-button size="mini" type="danger" @click="dele(scope.row._id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <Page></Page>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions, mapState, mapMutations } = createNamespacedHelpers("order");
import Page from "../page";
export default {
  components: {
    //设置引入其他文件的html
    Page,
  },

  created() {
    this.getSalesOrder();
  },
  computed: {
    ...mapState(["OrderData", "pageSize", "currentPage"]),
  },
  watch: {
    currentPage() {
      this.getSalesOrder();
    },
    pageSize() {
      this.getSalesOrder();
    },
  },
  methods: {
    ...mapActions(["getSalesOrder", "deletOrder"]),
    ...mapMutations(["setCurrent", "setPageSize"]),

    dele(row) {
      // 删除提示框
      this.$confirm("此操作将永久删除该订单, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "danger",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          this.deletOrder(row);
          this.getSalesOrder();
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>

<style>
</style>